package com.bjc.base.core;

import com.bjc.base.bean.ResultVO;

/**
 * 响应结果生成工具
 * 
 * @author 许自辉
 * @date 2017年7月15日
 */
public class ResultGenerator {
	private static final String DEFAULT_SUCCESS_MESSAGE = "成功";
	private static final String DELETE_SUCCESS_MESSAGE = "删除成功!成功条数：";
	private static final String INSERT_SUCCESS_MESSAGE = "添加成功!成功条数：";
	private static final String UPDATE_SUCCESS_MESSAGE = "更新成功!成功条数：";

	public static ResultVO getSuccess() {
		return new ResultVO(ResultEnum.SUCCESS.code, DEFAULT_SUCCESS_MESSAGE);
	}

	public static ResultVO getDeleteSuccess(int count) {
		return new ResultVO(ResultEnum.SUCCESS.code, DELETE_SUCCESS_MESSAGE + count);
	}

	public static ResultVO getInsertSuccess(int count) {
		return new ResultVO(ResultEnum.SUCCESS.code, INSERT_SUCCESS_MESSAGE + count);
	}

	public static ResultVO getUpdateSuccess(int count) {
		return new ResultVO(ResultEnum.SUCCESS.code, UPDATE_SUCCESS_MESSAGE + count);
	}

	public static ResultVO getSuccess(Object data) {
		return new ResultVO(ResultEnum.SUCCESS.code, DEFAULT_SUCCESS_MESSAGE, data);
	}

	public static ResultVO getFail(String message) {
		return new ResultVO(ResultEnum.FAIL.code, message);
	}
}
